home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
basic
/
bascrypt.bas
< prev
next >
Wrap
BASIC Source File
|
1991-02-27
|
2KB
|
46 lines
'BasEncrypt: Encryption/decryption routine
'Nelson Ford, Public (software) Library
'P.O.Box 35705, Houston, TX 77235-5705
'Call for free newsletter: 800-2424-PSL
'Information: 713-524-6394. CIS#: 71355,470
'This file can be freely used and copied for others so long as the file
'is not changed in any way.
'Purpose:
'''''''''
'Someone asked on the MSSYS forum on CompuServe for a simple encryption routine
'and the old XOR method was recommended.
'The accompanying routine is a lot more secure and just about as easy.
'Algorithm:
'''''''''''
'The idea is to set up a look-up substitution string for the ASCII character
'set, and replace each character in your text with the character assigned to
'that character's ASCII number position in the look-up string.
'In the sample code, the ASCII character set is simply reversed in the
'encryption string ("e$"). In actual use, you should assign the characters to
'the string more randomly. You should probably NOT change control characters
'[eg: leave the 13th character in the substitution string as CHR$(13)]
'so that you do not lose the ability to do INPUTs.
DEFINT A -Z: E$ = SPACE$(255) : D$ = SPACE$(255)
FOR I = 1 TO 255: MID$(E$, 256-I, 1) = CHR$(I): NEXT
FOR I = 1 TO 255: MID$(D$, ASC( MID$(E$,I))) = CHR$(I): NEXT
LINE INPUT "Enter text to encrypt: "; T$
FOR I = 1 TO LEN(T$)
MID$(T$, I, 1) = MID$(E$, ASC( MID$(T$, I)))
NEXT
PRINT T$
INPUT "Ready to decrypt"; x$
FOR I = 1 TO LEN(T$)
MID$(T$, I, 1) = MID$(D$, ASC( MID$(T$, I)))
NEXT
PRINT T$